package com.example.train_operate.util;

import com.example.train_operate.dto.HistoryMeetingDTO;
import com.example.train_operate.dto.OnlineCountDTO;
import com.example.train_operate.dto.RoomDTO;
import org.apache.commons.codec.digest.DigestUtils;

import static com.example.train_operate.constants.YunWuConstants.*;

public class RequestParamSet {

    /**
     * 设置默认参数
     * @param userId
     * @return
     */
    public static RoomDTO setDefaultParam(String userId){
        RoomDTO roomDTO = new RoomDTO();
        roomDTO.setRequestId(userId);
        roomDTO.setCompID(COMP_ID);
        roomDTO.setAppId(APP_ID);
        String compId = String.valueOf(COMP_ID);
        String secretKey = DigestUtils.md5Hex(compId + '&' + COMP_SECRET);
        roomDTO.setSecretKey(secretKey);
        return roomDTO;
    }

    /**
     * 设置指定参数
     * @param userId
     * @param roomId
     * @return
     */
    public static RoomDTO setSpecifyParam(String userId, String roomId){
        RoomDTO roomDTO = new RoomDTO();
        roomDTO.setRequestId(userId);
        roomDTO.setCompID(COMP_ID);
        roomDTO.setAppId(APP_ID);
        String compId = String.valueOf(COMP_ID);
        String secretKey = DigestUtils.md5Hex(compId + '&' + COMP_SECRET);
        roomDTO.setSecretKey(secretKey);
        roomDTO.setRoomId(roomId);
        return roomDTO;
    }

    /**
     * 设置查询在线人数参数
     * @param userId
     * @param roomId
     * @return
     */
    public static OnlineCountDTO setOnlineCountParam(String userId, String roomId){
        OnlineCountDTO onlineCountDTO = new OnlineCountDTO();
        onlineCountDTO.setRequestId(userId);
        onlineCountDTO.setCompID(COMP_ID);
        onlineCountDTO.setAppId(APP_ID);
        String compId = String.valueOf(COMP_ID);
        String secretKey = DigestUtils.md5Hex(compId + '&' + COMP_SECRET);
        onlineCountDTO.setSecretKey(secretKey);
        onlineCountDTO.setRoomIds(roomId);
        return onlineCountDTO;
    }

    /**
     * 设置查询历史房间参数
     * @param userId
     * @param roomId
     * @param startTime
     * @param endTime
     * @param pageNumber
     * @return
     */
    public static HistoryMeetingDTO setHistoryMeetingParam(String userId, Long roomId, Long startTime, Long endTime, Integer pageNumber){
        HistoryMeetingDTO historyMeetingDTO = new HistoryMeetingDTO();
        historyMeetingDTO.setRequestId(userId);
        historyMeetingDTO.setCompID(COMP_ID);
        String compId = String.valueOf(COMP_ID);
        String secretKey = DigestUtils.md5Hex(compId + '&' + COMP_SECRET);
        historyMeetingDTO.setSecretKey(secretKey);
        historyMeetingDTO.setRoomId(roomId);
        historyMeetingDTO.setStartTime(startTime);
        historyMeetingDTO.setEndTime(endTime);
        historyMeetingDTO.setPageNumber(pageNumber);
        historyMeetingDTO.setPageSize(PAGE_SIZE);
        return historyMeetingDTO;
    }

}
